package controller.listeners.configuration;

import model.ConfigurationModel;
import view.ConfigurationView;
import org.eclipse.swt.custom.TableEditor;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.widgets.Text;

public class RowModifyListener implements ModifyListener {

	private ConfigurationView _view;
	private ConfigurationModel _model;
	
	private TableEditor editor;
	private String key;
	
	public RowModifyListener(ConfigurationView view, ConfigurationModel model) {
		this._model = model;
		this._view = view;
	}
	
	public void setEditor(TableEditor editor) {
		this.editor = editor;
	}
	
	public void setKey(String key) {
		this.key = key;
	}
	
	@Override
	public void modifyText(ModifyEvent arg0) {
		Text text = (Text)editor.getEditor();
		String txt = text.getText();
		_model.changeKeyData(key, txt);
	}

}
